package com.zygh.questionnairesurvey.controller;

import com.zygh.questionnairesurvey.common.CommonResult;
import com.zygh.questionnairesurvey.entity.vo.QuestionsNumVo;
import com.zygh.questionnairesurvey.server.ExportExcelService;
import com.zygh.questionnairesurvey.server.StatisticalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @program: questionnaire-survey
 * @description: 统计
 * @author: ID-Tang
 * @create: 2021-05-18 09:07
 **/
@RestController
@RequestMapping(value = "/statistical")
@Api(tags = "统计")
public class StatisticalController {
    @Resource
    StatisticalService statisticalService;

    @RequestMapping(value = "/questionsNum", method = RequestMethod.GET)
    @ApiOperation(value = "统计问题数量占比")
    public Object questionsNum(@ApiParam(name = "deptId", value = "部门id")
                               @RequestParam(required = false) Integer deptId,
                               @ApiParam(name = "termStatus", value = "不为2：民警、领导班子   2：工勤人员）")
                               @RequestParam(required = false) Integer termStatus) {
        List<QuestionsNumVo> list = statisticalService.questionsNum(deptId, termStatus);
        return new CommonResult().success(list);
    }


    @RequestMapping(value = "/questionsPeople", method = RequestMethod.GET)
    @ApiOperation(value = "统计单个问题下各大队人数")
    public Object questionsPeople(@ApiParam(name = "lowest", value = "问题id", required = true)
                                  @RequestParam Integer lowest,
                                  @ApiParam(name = "termStatus", value = "不为3：民警、领导班子   3：工勤人员）")
                                  @RequestParam(required = false) Integer termStatus) {
        List list = statisticalService.questionsPeople(lowest, termStatus);

        return new CommonResult().success(list);
    }


    @RequestMapping(value = "/detailNum", method = RequestMethod.GET)
    @ApiOperation(value = "统计单个问题下各大队问题详情条数")
    public Object detailNum(@ApiParam(name = "encoder", value = "问题编号")
                            @RequestParam(required = false) String encoder,
                            @ApiParam(name = "termStatus", value = "不为3：民警、领导班子   3：工勤人员）")
                            @RequestParam(required = false) Integer termStatus) {
        List list = statisticalService.detailNum(encoder, termStatus);

        return new CommonResult().success(list);
    }


}
